package com.example.listviewcontacts;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.SyncStateContract.Columns;

public class ContactInfoDBHelper extends SQLiteOpenHelper {

	public static final String DATABASE_NAME = "myapp.db";
	public static final String TABLE_NAME = "contactInfo";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_SIP_ADDRESS = "sip";
	public static final String COLUMN_NAME = "name";
	public static final String COLUMN_SURNAME = "surname";
	public static final String COLUMN_KEY = "key";
	public static final String COLUMN_EXPIRE = "expire";
	public static final int VERSION = 1;

	public ContactInfoDBHelper(Context context) {
		super(context, DATABASE_NAME, null, VERSION);

	}

	private static final String DATABASE_CREATE = "create table " + TABLE_NAME
			+ "(" + COLUMN_ID + " integer primary key autoincrement,"
			+ COLUMN_SIP_ADDRESS + " text," + COLUMN_NAME
			+ " text not null," + COLUMN_SURNAME + " text not null,"
			+ COLUMN_KEY + " text," + COLUMN_EXPIRE + " integer" + ")";

	@Override
	public void onCreate(SQLiteDatabase db) {

		db.execSQL(DATABASE_CREATE);

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " +TABLE_NAME);
		onCreate(db);

	}

}
